<?php if (!defined('ITPK')) exit('You can not directly access the file.');

/**
 * 用户操作类
 * @author 冬天的秘密
 * @link http://bbs.itpk.cn
 * @version 1.0
 */

class WebuserPer extends WebDBConnection {

	/**
	 * 用户登录
	 * @param string $username
	 * @param string $password
	 * @return Ambigous <multitype:, boolean>
	 */
	public function login($username, $password) {
		return $this->db->executeQuery("SELECT * FROM web_user WHERE username = '{$username}' AND password = '" . md5($password) . "' ORDER BY id ASC LIMIT 1", true);
	}

	/**
	 * 检查用户的Cookie是否正确
	 * @param string $user_check
	 * @return Ambigous <multitype:, boolean>
	 */
	public function checkUser($user_check) {
		return $this->db->executeQuery("SELECT * FROM web_user WHERE user_check = '{$user_check}' ORDER BY id ASC LIMIT 1", true);
	}

	/**
	 * 更换Cookie
	 * @param int $id
	 * @param string $user_check
	 * @return Ambigous <multitype:, boolean>
	 */
	public function updateUserCheck($id, $user_check) {
		return $this->db->executeQuery("UPDATE web_user SET user_check = '{$user_check}' WHERE id = {$id}");
	}

}
?>